package com.coldlz.mmp.pojo;

import java.util.Objects;

public class Result<T> {
    private String msg;
    private Integer code;
    private T data;

    public Result() {
        this(null, null, null);
    }

    public Result(String msg, Integer code, T data) {
        this.msg = msg;
        this.code = code;
        this.data = data;
    }

    public static Result<Object> ok() {
        return new Result<>("ok", 200, "");
    }

    public static <T> Result<T> ok(T data) {
        return new Result<T>("ok", 200, data);
    }

    public static <T> Result<T> error(String msg) {
        return new Result<T>(msg, 400, null);
    }


    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
